<% content_for :settings do %>

  <%= settings_header('integration') %>

  <%= bootstrap_form_tag url: admin_update_integration_settings_path(return_to: 'integration'), method: 'put', multipart: true, authenticity_token: true do |f| %>
    <div class="settings-section integrations" data-hook="admin_settings_integrations">
      <div class="row integration-item vcenter">
        <div class="col-md-6">
          <span class="more-important">Incoming Webhook</span>
          <p class="less-important">
            Create tickets from existing webforms by POSTing to a JSON webhook
            URL. Your secret URL is:<br/>
            <%= f.check_box 'webhook.form_enabled', { checked: (AppSettings['webhook.form_enabled'] == '1'), label: t('enable_webhook_url', default: "Enable Incoming Webhooks"), label_class: 'full-width', class: 'bs-toggle', data: { size: 'mini' } } %>
            <h4></h4>
          </p>
        </div>
        <div class="col-md-6">
          <%= text_field_tag 'URL', '', value: "#{request.protocol}#{request.host_with_port}/webhook/form/#{AppSettings["webhook.form_key"]}/", class: 'form-control' %>
        </div>
      </div>
      <div class="row integration-item vcenter">
        <div class="col-md-6">
          <span class="more-important">Google Analytics</span>
          <p class="less-important">
            Send Helpdesk usage statistics into Google Analytics for reporting
            and visualization.
            <%= f.check_box 'settings.google_analytics_enabled', { checked: (AppSettings['settings.google_analytics_enabled'] == '1'), label: t('enable_google_analytics', default: "Enable Google Analytics"), label_class: 'full-width', class: 'bs-toggle', data: { size: 'mini' } } %>
          </p>
        </div>
        <div class="col-md-6">
          <%= f.text_field 'settings.google_analytics_id', value: AppSettings['settings.google_analytics_id'], label: "Google Analytics ID" %>
        </div>
      </div>
      <div class="row integration-item vcenter">
        <div class="col-md-6">
          <span class="more-important">Recaptcha</span>
          <p class="less-important">
            Recaptcha helps protect your self service helpdesk from spam.
            <%= f.check_box 'settings.recaptcha_enabled', { checked: (AppSettings['settings.recaptcha_enabled'] == '1'), label: t('enable_recaptcha', default: "Enable Recaptcha"), label_class: 'full-width', class: 'bs-toggle', data: { size: 'mini' } } %>
          </p>
        </div>
        <div class="col-md-6">
          <%= f.text_field 'settings.recaptcha_site_key', value: AppSettings['settings.recaptcha_site_key'], label: t('recaptcha_site_key', default: "Recaptcha Site Key") %>
          <%= f.text_field 'settings.recaptcha_api_key', value: AppSettings['settings.recaptcha_api_key'], label: t('recaptcha_api_key', default: "Recaptcha API Key") %>
        </div>
      </div>
      <div class="row integration-item vcenter">
        <div class="col-md-6">
          <span class="more-important">Cloudinary</span>
          <p class="less-important">
            Cloudinary offers image hosting and transformation services.
            <%= f.check_box 'cloudinary.enabled', { checked: (AppSettings['cloudinary.enabled'] == '1'), label: t('enable_cloudinary', default: "Enable Cloudinary"), label_class: 'full-width', class: 'bs-toggle', data: { size: 'mini' } } %>
          </p>
        </div>
        <div class="col-md-6">
          <%= f.text_field 'cloudinary.cloud_name', value: AppSettings['cloudinary.cloud_name'], label: "Cloudinary Cloud Name" %>
          <%= f.text_field 'cloudinary.api_key', value: AppSettings['cloudinary.api_key'], label: "Cloudinary API Key" %>
          <%= f.password_field 'cloudinary.api_secret', value: AppSettings['cloudinary.api_secret'], label: "Cloudinary API Secret" %>
        </div>
      </div>

    </div>
    <div class="submit-section">
      <%= f.submit "Save Settings", class: 'btn btn-warning' %>
    </div>
  <% end %>
<% end %>
